<?php
require_once("sys_conf.inc");
if (isset($_POST["option"]))
{
	$option = $_POST["option"];
	$link_id = mysql_connect($DBHOST,$DBUSER,$DBPWD);
	mysql_select_db($DBNAME);
	mysql_query("SET NAMES 'utf8'");
	$id = $option["id"];
	$subjectid = $option["subid"];
	$name = strip_tags($option["name"]);
	$introduction = strip_tags($option["introduction"]);
	if(!$id){
		$createTime = date("Y-m-d H:i:s");
		$sql = "insert into extpollitems(subjectid,name,introduction) values('$subjectid','$name','$introduction')";
		mysql_query($sql);
		echo "<script>alert('添加成功!');</script>";
	}else{
		$sql = "UPDATE extpollitems SET subjectid = '$subjectid',name = '$name', introduction = '$introduction'  WHERE id = '$id'";
		mysql_query($sql);
		echo "<script>alert('修改成功!');</script>";
	}
	header('Location: ../poll_add.php?id='.$subjectid);
}
?>
